package zuoye;

import util.Util;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Menujpanel extends JPanel implements ActionListener {
    private JButton SavejButton;
    private Icon saveimage = Util.getIcon("/images/buttonSave.jpg");
    private JButton GetjButton;
    private Icon getimage = Util.getIcon("/images/buttonGet.jpg");
    private JButton FindjButton;
    private Icon findimage = Util.getIcon("/images/buttonFind.jpg");
    private JButton OffjButton;
    private Icon offimage = Util.getIcon("/images/buttonOff.jpg");
    private Mainjframe frame;

    public Menujpanel(Mainjframe frame) {
        this.frame = frame;
        this.setLayout(null);
        this.setOpaque(false);

        SavejButton = new JButton(saveimage);
        SavejButton.setBounds(50, 50, 140, 50);
        this.add(SavejButton);
        SavejButton.addActionListener(this);

        GetjButton = new JButton(getimage);
        GetjButton.setBounds(50, 250, 140, 50);
        this.add(GetjButton);
        GetjButton.addActionListener(this);

        FindjButton = new JButton(findimage);
        FindjButton.setBounds(50, 450, 140, 50);
        this.add(FindjButton);
        FindjButton.addActionListener(this);

        OffjButton = new JButton(offimage);
        OffjButton.setBounds(50, 650, 140, 50);
        this.add(OffjButton);
        OffjButton.addActionListener(this);

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == SavejButton) {
            frame.switchPanel("Save");
        } else if (e.getSource() == GetjButton) {
            frame.switchPanel("Get");
        } else if (e.getSource() == FindjButton) {
            frame.switchPanel("Find");
        } else if (e.getSource() == OffjButton){
            System.exit(0);
        }
    }
}
